import request from '@/utils/request'

// 用户登录接口
export const loginAPI = (username, password) => {
    return request({
        url: '/admin/login',
        method: 'post',
        data: {
            username,
            password
        }
    })
}

// 获取用户信息接口
export const getInfo = () => {
    return request({
        url: '/admin/info',
        method: 'get'
    })
}

// 退出登录接口
export const logout = () => {
    return request({
        url: '/admin/logout',
        method: 'post'
    })
}

// 获取用户列表接口
export const fetchUserList = (params) => {
    return request({
        url: '/admin/list',
        method: 'get',
        params: params
    })
}

// 创建管理员
export const createAdmin = (data) => {
    return request({
        url: '/admin/register',
        method: 'post',
        data: data
    })
}

// 更新管理员
export const updateAdmin = (id, data) => {
    return request({
        url: '/admin/update' + id,
        method: 'post',
        data: data
    })
}

// 更新状态
export const updateAdminStatus = (id, params) => {
    return request({
        url: '/admin/updateStatus/' + id,
        method: 'post',
        params: params
    })
}

// 删除管理员
export const deleteAdmin = (id) => {
    return request({
        url: '/admin/delete/' + id,
        method: 'post'
    })
}

// 分配管理员角色列表
export const getRoleByAdmin = (id) => {
    return request({
        url: '/admin/role/' + id,
        method: 'get'
    })
}

// 分配角色
export const allocRole = (data) => {
    return request({
        url: '/admin/role/update',
        method: 'post',
        data: data
    })
}


